package com.atguigu.cloud.controller;

import com.aiguigu.cloud.apis.ArticleFeignApi;
//import com.atguigu.cloud.apis.ArticleFeignApi;
import com.aiguigu.cloud.entities.ArticleDTO;
import com.aiguigu.cloud.resp.ResultData;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class WriteController {
    @Resource
    private ArticleFeignApi articleFeignApi;

    @GetMapping(value = "/feign/article/add")
    public ResultData<String> addArticle(@RequestBody ArticleDTO articleDTO){
        return articleFeignApi.addArticle(articleDTO);
    }

    @GetMapping(value = "/feign/article/delete/{id}")
    public ResultData<Integer> deleteArticle(@PathVariable("id") Integer id){
        return articleFeignApi.deleteArticle(id);
    }

    @GetMapping(value = "/feign/article/update")
    public ResultData<String> updateArticle(@RequestBody ArticleDTO articleDTO){
        return articleFeignApi.updateArticle(articleDTO);
    }

    @GetMapping(value = "/feign/article/get/{id}")
    public ResultData getById(@PathVariable("id") Integer id){
        return articleFeignApi.getById(id);
    }

    @GetMapping(value = "/feign/article/get/info")
    public String getInfoByConsul(){
        return articleFeignApi.myLoadBalancer();
    }
}
